package com.buddies.lottery.data.bean;

import com.buddies.lottery.utils.DateUtils;

import java.io.Serializable;
import java.util.Date;

public class LotteryRule implements Serializable {

    public String start;
    public String end;
    public int duration;

    public boolean isInRuleTime() {
        Date startDate = DateUtils.parse(start);
        Date endDate = DateUtils.parse(end);
        Date date = new Date();
        return date.after(startDate) && date.before(endDate);
    }

    public int getDuration() {
        if (duration == 0) {
            duration = (int) ((DateUtils.parse(end).getTime() - System.currentTimeMillis()) / 1000);
        }
        return duration;
    }

}
